package com.lj.sys.result;

import com.lj.sys.entity.SysConfig;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;

/**
 * <p>
 * 系统配置表 分页结果
 * </p>
 *
 * @author luojing
 * @since 2025-02-21 14:11:02
 */
@Data
@Schema(description = "系统配置表 分页结果")
public class SysConfigPageResult {

    @Schema(description = "主键id ")
    private Long id;

    @Schema(description = "配置key ")
    private String configKey;

    @Schema(description = "配置值 ")
    private String configValue;

    @Schema(description = "分类 参考字典: SysConfigCategory")
    private Integer category;

    @Schema(description = "备注 ")
    private String remark;

    @Schema(description = "更新时间 ")
    private LocalDateTime updateTime;

    public static SysConfigPageResult of(SysConfig entity) {
        if (entity == null) {
            return null;
        }
        SysConfigPageResult result = new SysConfigPageResult();
        result.setId(entity.getId());
        result.setConfigKey(entity.getConfigKey());
        result.setConfigValue(entity.getConfigValue());
        result.setCategory(entity.getCategory().getValue());
        result.setRemark(entity.getRemark());
        result.setUpdateTime(entity.getUpdateTime());
        return result;
    }
}
